import subprocess
import sys
import os

from video_converter import VideoConverter
from audio_converter import AudioConverter
from image_converter import ImageConverter


class MediaConverter:
    def __init__(self):
        self.selected_file = None
        self.selected_image = None
        self.selected_audio = None
        
        # 初始化各个转换器
        self.video_converter = VideoConverter()
        self.audio_converter = AudioConverter()
        self.image_converter = ImageConverter()
    
    def is_valid_audio_file(self, file_path):
        """使用ffprobe检测文件是否为有效的音频文件"""
        return self.audio_converter.is_valid_audio_file(file_path)
    


    def convert_video(self, input_path):
        """转换视频文件"""
        return self.video_converter.convert_video(input_path)

    def convert_image(self, input_path, output_format="jpg"):
        """转换图片文件"""
        return self.image_converter.convert_image(input_path, output_format)

    def convert_audio(self, input_path, output_format="wav"):
        """转换音频文件"""
        return self.audio_converter.convert_audio(input_path, output_format)
